package com.rulin.asp.business.datacleaning.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rulin.asp.business.datacleaning.entity.QuestionNew;
import com.rulin.asp.business.datacleaning.mapper.QuestionNewMapper;
import com.rulin.asp.sso.entity.UserUtils;

@Service
public class DataCleanService {

	@Autowired
	private QuestionNewMapper questionNewMapper;
	
	public void saveData(QuestionNew data) {
		int i = questionNewMapper.update(data);
		if(i == 0) {
			data.setCreateTime(new Date());
			String uploadUid = UserUtils.getUser().getId();
			data.setUploadUid(uploadUid);
			questionNewMapper.insert(data);
		}
	}
	
	public QuestionNew getQuestion(String id) {
		QuestionNew question = questionNewMapper.selectByPrimaryKey(id);
		if(question == null) {
			question = new QuestionNew();
			question.setId(id);
			question.setCreateTime(new Date());
			return question;
		}
		return question;
	}
}
